-
-
Notifications
You must be signed in to change notification settings - Fork 6
Feature Add Splat Registrations to IViewFor Generator #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces SplatRegistrationType to IViewFor attributes and source generator, enabling automatic registration of views for view models in Splat's service locator. Updates documentation, tests, and sample usage to demonstrate new registration options and extension method for bulk registration.
…eGeneratorsExtensions.g.verified.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces Splat integration to the IViewFor source generator, enabling automatic registration of views with view models in Splat's service locator. It adds a SplatRegistrationType parameter to IViewFor attributes and generates an extension method for bulk registration of all views.
- Adds
SplatRegistrationTypeenum with options: None, LazySingleton, Constant, PerRequest - Extends IViewFor attributes to support
RegistrationTypeparameter for Splat registration - Generates
RegisterViewsForViewModelsSourceGenerated()extension method for bulk view registration
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| IViewForInfo.cs | Adds SplatRegistrationType property to track registration type |
| IViewForGenerator.cs | Updates generator to produce registration extension method |
| IViewForGenerator.Execute.cs | Implements registration extension generation logic |
| AttributeDefinitions.cs | Defines SplatRegistrationType enum and updates IViewFor attributes |
| Test files | Updates examples to demonstrate Splat registration usage |
| README.md | Documents new Splat registration functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| public static void Main() => Application.Run(new TestViewWinForms()); | ||
| public static void Main() | ||
| { | ||
| AppLocator.CurrentMutable.RegisterViewsForViewModelsSourceGenerated(); |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use Locator.CurrentMutable instead of AppLocator.CurrentMutable to match the Splat API and be consistent with other usages in the codebase.
| AppLocator.CurrentMutable.RegisterViewsForViewModelsSourceGenerated(); | |
| Locator.CurrentMutable.RegisterViewsForViewModelsSourceGenerated(); |
| public TestViewWpf() => ViewModel = TestViewModel.Instance; | ||
| public TestViewWpf() | ||
| { | ||
| Locator.CurrentMutable.RegisterLazySingleton<IViewFor<TestViewModel>>(() => new TestViewWpf()); |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This manual registration should be removed since the PR introduces automatic registration via the generated extension method, making this redundant.
| Locator.CurrentMutable.RegisterLazySingleton<IViewFor<TestViewModel>>(() => new TestViewWpf()); |
| /// </summary> | ||
| /// <seealso cref="System.Attribute" /> | ||
| [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.IViewForGenerator", "1.1.0.0")] | ||
| [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveObjectGenerator", "1.1.0.0")] |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GeneratedCode attribute should reference 'ReactiveUI.SourceGenerators.IViewForGenerator' instead of 'ReactiveObjectGenerator' for consistency with the actual generator.
| [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveObjectGenerator", "1.1.0.0")] | |
| [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.IViewForGenerator", "1.1.0.0")] |
| /// </summary> | ||
| internal static class ReactiveUISourceGeneratorsExtensions | ||
| { | ||
| [global::System.CodeDom.Compiler.GeneratedCode("{{GeneratorName}}", "{{GeneratorVersion}}")] |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template placeholders {{GeneratorName}} and {{GeneratorVersion}} are not being replaced with actual values, which will result in literal placeholder text in the generated code.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What kind of change does this PR introduce?
Feature
What is the new behavior?
Introduces SplatRegistrationType to IViewFor attributes and source generator, enabling automatic registration of views for view models in Splat's service locator.
Updates documentation, tests, and sample usage to demonstrate new registration options and extension method for bulk registration.
What might this PR break?
None
Please check if the PR fulfills these requirements
Other information: